package org.ruanjj.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PokerTest {
    public static void main(String[] args) {
        String[] num = {"3","4","5","6","7","8","9","10","J","P","K","A","2"};
        String[] color = {"红桃","黑桃","方块","梅花"};

        List poker = new ArrayList();
        //制作扑克
        for(int i =0; i < num.length; i++){
            for(int j = 0; j < color.length; j++){
                poker.add(color[j]+num[i]);
            }
        }

        poker.add("大王");
        poker.add("小王");

        //洗牌
        Collections.shuffle(poker);

        //发牌
        List tom = new ArrayList();
        List jerry = new ArrayList();
        List me = new ArrayList();
        List remain = new ArrayList();

        for(int i = 0; i < poker.size(); i++){
            if(i >= poker.size()-3){
                remain.add(poker.get(i));
            }else if(i % 3 == 0){
                tom.add(poker.get(i));
            }else if(i % 3 == 1){
                jerry.add(poker.get(i));
            }else if(i % 3 == 2){
                me.add(poker.get(i));
            }
        }

        //打印
        System.out.println("Tom的牌:");
        System.out.println(tom);

        System.out.println("Jerry的牌:");
        System.out.println(jerry);

        System.out.println("康师傅的牌:");
        System.out.println(me);

        System.out.println("剩下的底牌:");
        System.out.println(remain);
    }

}
